﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using Silvermoon.WinControls;
using ShoppingList.Biz;
using Silvermoon.Controls.Forms;

namespace ShoppingList
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            BizContext.Open();
            BizContext.Context.DatabaseException += new EventHandler<ShoppingList.DAL.DatabaseExceptionEventArgs>(Context_DatabaseException);
            SMApplication.Run<ShoppingListPage>("Shopping List");
            BizContext.Close();
        }

        static void Context_DatabaseException(object sender, ShoppingList.DAL.DatabaseExceptionEventArgs e)
        {
            Silvermoon.Core.Screen screen = Silvermoon.Core.Screen.Current;
            if (screen != null)
            {
                string s = string.Format("At {0}:\n{1}",e.Exception.Message,e.Exception.InnerException.Message);
                MessageDialog.Show("DATABASE ERROR", s);
            }
        }
    }
}